// pages/bailin/bailin.js
Page({

    /**
     * 页面的初始数据
     */
    data: {
        longitude:99.5,
        latitude:54.67,
    },
    /**
     * 生命周期函数--监听页面加载
     */
    onLoad(options) {
        this.fs = wx.getFileSystemManager()
    },
    onLocationChange(){
        const _locationChangeFn = function(res) {
            console.log('location change', res)
        }
        wx.onLocationChange(_locationChangeFn)
        wx.offLocationChange(_locationChangeFn)
    },
    opensettint(){
        wx.openSetting({
            success(res){
                console.log(res);
            },
            fail(res){
                console.log(res);
            }
        })
    },
    // 实时获取位置
    onlocation(){
        wx.startLocationUpdateBackground({
            type:'gcj02',
            success(res){
                console.log(res);
            },
            fail(res){
                console.log(res);
            }
        })
    },
    chooselocation(){
        let latitude = this.data.latitude
        let longitude = this.data.longitude
        wx.chooseLocation({
          latitude: latitude,
          longitude:longitude,
          success(res){
            console.log(res);
          },
          fail(res){
            console.log(res);
          }
        })
    },
    dakai(){
        let that = this
        wx.getLocation({
            type: 'wgs84',
            altitude:true,
            isHighAccuracy:true,
            success (res) {
              const latitude = res.latitude
              const longitude = res.longitude
              const speed = res.speed
              const accuracy = res.accuracy
              that.setData({
                longitude:longitude,
                latitude:latitude
              })
              console.log(latitude);
              console.log(longitude);
              console.log(speed);
              console.log(accuracy);
            }
           })
    },
    /**
     * 生命周期函数--监听页面显示
     */
    onShow() {

    },

    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide() {

    },

    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload() {

    },

    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh() {

    },

    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom() {

    },

    /**
     * 用户点击右上角分享
     */
    onShareAppMessage() {

    }
})